<?php include _include(ADMIN_PATH.'view/htm/header.inc.htm');?>

<!--{hook admin_user_update_start.htm}-->

<div class="row">
	<div class="col-lg-8 offset-lg-2">
		<div class="btn-group m-b-1" role="group">
			<?php echo admin_tab_active($menu['user']['tab'], 'finance');?>
		</div>
		<div class="card">
			<div class="card-block">
				<h4 class="card-title">编辑财务</h4>
				<form action="<?php echo url("user-financeupdate-$_uid");?>" method="post" id="form">					
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">用户名：</label>
						<div class="col-sm-10">
							<input type="text" id="username" name="username" class="form-control" value="<?php echo $_user['username'];?>">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">登陆密码：</label>
						<div class="col-sm-10">
							<input type="text" id="password" name="password" class="form-control" placeholder="不修改请留空">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">IP白名单：</label>
						<div class="col-sm-10">
							<input type="text" id="allow_ips" name="allow_ips" class="form-control" value="<?php echo $_user['allow_ips'];?>" placeholder="多个地址用,号分隔 留空为不限制">
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">权限</label>
						<div class="col-sm-10">
							<?php if($merchant){?>
							商户<br>
							<?php foreach($merchant as $m){ ?>
								<input type="checkbox" name="power[]" id="power_<?php echo $m['uid']?>" value="<?php echo $m['uid']?>" <?php if(in_array($m['uid'],$power_old)){echo 'checked="checked"';}?> /><label for="power_<?php echo $m['uid']?>"><?php echo $m['username']?></label>&nbsp;
							<?php }}?>
							<?php if($proxy){?>
							<hr />
							代理<br>
							<?php foreach($proxy as $p){ ?>
								<input type="checkbox" name="power[]" id="power_<?php echo $p['uid']?>" value="<?php echo $p['uid']?>" <?php if(in_array($p['uid'],$power_old)){echo 'checked="checked"';}?> /><label for="power_<?php echo $p['uid']?>"><?php echo $p['username']?></label>&nbsp;
							<?php }}?>
						</div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">注册时间：</label>
						<div class="col-sm-10"><?php echo date('Y-m-d H:i:s',$_user['create_time']);?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">注册IP：</label>
						<div class="col-sm-10"><?php echo $_user['create_ip'];?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">登录时间：</label>
						<div class="col-sm-10"><?php echo $_user['login_time']?date('Y-m-d H:i:s',$_user['login_time']):'';?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label">登录IP：</label>
						<div class="col-sm-10"><?php echo $_user['login_ip'];?></div>
					</div>
					<div class="form-group row">
						<label class="col-sm-2 form-control-label"></label>
						<div class="col-sm-10">
							<button type="submit" class="btn btn-primary btn-block" id="submit" data-loading-text="提交中...">确认</button>
							<a role="button" class="btn btn-secondary btn-block m-t-1" href="javascript:history.back();">返回</a>
						</div>
					</div>
				</form>
			</div>
		</div>
	</div>
</div>

<!--{hook admin_user_update_end.htm}-->

<?php include _include(ADMIN_PATH.'view/htm/footer.inc.htm');?>


<script>
var jform = $('#form');
var jsubmit = $('#submit');
jform.on('submit', function() {
	jform.reset();
	jsubmit.button('loading');
	var postdata = jform.serialize();
	$.xpost(jform.attr('action'), postdata, function(code, message) {
		if(code == 0) {
			$.alert(message);
			jsubmit.text(message).delay(3000).button('reset');
		} else if(code < 0) {
			$.alert(message);
			jsubmit.button('reset');
		} else {
			alert(message);
			jform.find('[name="'+code+'"]').alert(message).focus();
			jsubmit.button('reset');
		}
	});
	return false;
});

$('#nav_pc li.user, #nav_mobile li.user').tab('show');

</script>